package com.zzu.utils;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.widget.Toast;

/**
 * @ClassName ToastUtils
 * @Description TODO
 * @Author ZB
 * @Date 2021/5/20 9:33
 * @Version 1.0
 **/
public class ToastAndDialogUtils {

    //显示短的Toast
    public static void showShort(Context context,String str){
        if(context != null){
            Toast.makeText(context,str,Toast.LENGTH_SHORT).show();
        }

    }
    public static void showLong(Context context,String str){
        if(context != null){
            Toast.makeText(context,str,Toast.LENGTH_LONG).show();
        }
    }

    //显示对话框
    public static ProgressDialog showDialog(Context context,String str){
        if(context != null){
            //加载进度条
            ProgressDialog dialog = ProgressDialog.show(context, "提示", str);
            //设置点击返回键取消对话框
            dialog.setCancelable(true);
            return dialog;
        }
        return null;
    }
    //取消对话框
    public static void cancelDialog(ProgressDialog dialog){
        if(dialog != null){
            dialog.dismiss();
        }

    }
}
